<div class="menu">
<h2 class="h2-title">Quản lý menu !!!</h2>

<p><a href="<?=base_url()?>backend/menu/createmenu" class="bnt"style="margin-bottom: 15px;">Tạo menu</a></p>

<div class="clear"></div>
<?php if($this->native_session->flashdata('msg')):?>
    <ul class="notification succ">
        <li class="notifi_img"><img src="<?=base_url()?>assets/backend/css/images/icons/tick_circle.png"/></li>

        <li class="msg"><?=$this->native_session->flashdata('msg')?></li>

        <li class="close"><img src="<?=base_url()?>assets/backend/css/images/icons/cross_grey_small.png"/></li>

    </ul><!--End of .notification -->
<?php endif?>

<table class="pretty">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Tên menu</th>
                            <th>Tên menu cha</th>
                            <th>Trạng thái</th>
                            <th>Sửa</th>
                            <th>Xoá</th>
                        </tr>
                    </thead>

                    <tbody>
                        <?php foreach($menus as $menu):?>
                            <tr>
                                <td><?=$menu->menu_id?></td>
                                <td><?=$menu->menu_name?></td>
                                <?php $menu_parent = getMenuParentName($menus,$menu->menu_parent) ?>
                                <?php if(!$menu_parent):?>
                                    <td>Không có</td>
                                <?php else:?>
                                    <td><?=$menu_parent?> </td>
                                <?php endif;?>
                                <?php if($menu->menu_status == 1):?>
                                    <td><a href="<?=base_url()?>backend/menu/changestt/<?=$menu->menu_id?>/0" style="color: #437C00;" title="Ấn để ẩn">Hiển thị</a></td>
                                <?php else:?>
                                    <td><a href="<?=base_url()?>backend/menu/changestt/<?=$menu->menu_id?>/1" style="color: #437C00;" title="Ấn để hiển thị">Ẩn</a></td>
                                <?php endif;?>
                                <td>
                                    <a href="<?=base_url()?>backend/menu/editmenu/<?=$menu->menu_id?>" class="edit">
                                        <img src="<?=base_url()?>assets/backend/css/images/edit.png"/>
                                    </a>
                                </td>
                                <td>
                                    <a href="<?=base_url()?>backend/menu/delmenu/<?=$menu->menu_id?>" class="delete">
                                        <img src="<?=base_url()?>assets/backend/css/images/delete.png"/>
                                    </a>
                                </td>
                            </tr>
                        <?php endforeach;?>
                    </tbody>
                </table>
</div>
<?php

    function getMenuParentName($menus,$menu_parent)
    {
        foreach($menus as $menu)
        {
            if($menu->menu_id == $menu_parent)
                return $menu->menu_name;
        }

        return FALSE;
    }

?>